package zj.it.bhne.gridengineeringsurvey.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.baidu.mapapi.map.offline.MKOLSearchRecord;
import com.baidu.mapapi.map.offline.MKOLUpdateElement;
import com.baidu.mapapi.map.offline.MKOfflineMap;
import com.baidu.mapapi.map.offline.MKOfflineMapListener;
import com.flyco.dialog.listener.OnBtnClickL;
import com.flyco.dialog.widget.NormalDialog;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import zj.it.bhne.gridengineeringsurvey.BaseActivity;
import zj.it.bhne.gridengineeringsurvey.R;
import zj.it.bhne.gridengineeringsurvey.adapter.CityChildAdapter;
import zj.it.bhne.gridengineeringsurvey.entity.OffLinebBean;
import zj.it.bhne.gridengineeringsurvey.myutils.MyUtils;
import zj.it.bhne.gridengineeringsurvey.myutils.map.models.OfflineMapItem;
/* 此Demo用来演示离线地图的下载和显示 */
public class OfflineDemo extends BaseActivity implements MKOfflineMapListener, OnClickListener {
    private static final String TAG = "OfflineDemo";
    private String name="haha";
    private MKOfflineMap mOffline = null;
    //private TextView cidView;
    //private TextView stateView;
    private EditText cityNameView;
    private Context context;
    /**
     * 已下载的离线地图信息列表
     */
    private ArrayList<MKOLUpdateElement> localMapList = null;
    private LocalMapAdapter lAdapter = null;
    private Button clButton;
    private Button localButton,clButton1;
    private List<OfflineMapItem> itemsDown; //下载或下载中城市
    private List<OfflineMapItem> itemsAll;  //所有城市，与热门城市及下载管理对象相同
    private List<OfflineMapItem> itemsProvince;
    private List<List<OfflineMapItem>> itemsProvinceCity;



    private ExpandableListView mElv;
    private ExpandableListViewAdapter mExpandableListViewAdapter;
    private ArrayList<Object> mHeadertop;
    private ArrayList<String> hotCityNames;
    private ArrayList<String> hotCities;
    ArrayList<OffLinebBean> mDatas;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_offline);
        context = this;
        try {
            mOffline = new MKOfflineMap();
            mOffline.init(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        initView();

    }

    private Button search;

    private void initView() {

        //cidView = (TextView) findViewById(R.id.cityid);
        cityNameView = (EditText) findViewById(R.id.city);
        search = findViewById(R.id.search);
        //stateView = (TextView) findViewById(R.id.state);

        
        //TODO START 
        View headerView = LayoutInflater.from(this).inflate(R.layout.exlistview_header, null);
        mElv = findViewById(R.id.expandableListView);


        //TODo 获取热门城市列表
        ListView hotCityList = (ListView) headerView.findViewById(R.id.hotcitylist);
        hotCities = new ArrayList<String>();
        ArrayList<MKOLSearchRecord> records_Tianjin = mOffline.searchCity("天津市");
        hotCityNames = new ArrayList<String>();

        final List<Integer> integerList = new ArrayList<>();
        // 获取热闹城市列表
        ArrayList<MKOLSearchRecord> records1 = mOffline.getHotCityList();
        hotCities.add("天津市"+"("+records_Tianjin.get(0).cityID+")"+"   --"+ this.formatDataSize(records_Tianjin.get(0).dataSize));
        hotCityNames.add(records_Tianjin.get(0).cityName);
        integerList.add(records_Tianjin.get(0).cityID);
        if (records1 != null) {
            for (MKOLSearchRecord r : records1) {
                //V4.5.0起，保证数据不溢出，使用long型保存数据包大小结果
                hotCities.add(r.cityName + "(" + r.cityID + ")" + "   --"
                        + this.formatDataSize(r.dataSize));
                hotCityNames.add(r.cityName);
                integerList.add(r.cityID);
            }
        }
        //Log.e("size=",hotCities.size()+"");
        ListViewsExpanderTop hadapterss = new ListViewsExpanderTop(this);
        hotCityList.setAdapter(hadapterss);
        hotCityList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @SuppressLint("SetTextI18n")
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                cityNameView.setText(hotCityNames.get(i));
                //cidView.setText(integerList.get(i) + "");
                cityId = integerList.get(i);
            }
        });


        //TODO 获取所有支持离线地图的城市
        mDatas = new ArrayList<>();
        ArrayList<MKOLSearchRecord> mrecord = mOffline.getOfflineCityList();
        if (mrecord != null) {
            //遍历所有的省城市
            for (int i = 0; i < mrecord.size(); i++) {
                OffLinebBean offLinebBean = new OffLinebBean();
                offLinebBean.cityName = mrecord.get(i).cityName;
                offLinebBean.cityId = mrecord.get(i).cityID;
                offLinebBean.cityInformessage = mrecord.get(i).cityName + "(" + mrecord.get(i).cityID + ")" + "   --" + this.formatDataSize(mrecord.get(i).dataSize);
                if (mrecord.get(i).childCities != null) {
                    if (mrecord.get(i).childCities.size() > 0) {//如果是省份那么有下面的市
                        for (int j = 0; j < mrecord.get(i).childCities.size(); j++) {
                            OffLinebBean.CityChilden cityChilden = new OffLinebBean.CityChilden();
                            cityChilden.cityChildId = mrecord.get(i).childCities.get(j).cityID;
                            cityChilden.cityChildName = mrecord.get(i).childCities.get(j).cityName;
                            cityChilden.cityChildInformessage = mrecord.get(i).childCities.get(j).cityName + "(" + mrecord.get(i).childCities.get(j).cityID+ ")" + "   --"
                                    + this.formatDataSize(mrecord.get(i).childCities.get(j).dataSize);
                            offLinebBean.citychildList.add(cityChilden);
                        }
                    }
                    mDatas.add(offLinebBean);
                }
            }
        }
        //TODO 获取全国离线地图，并展示在上面
        mExpandableListViewAdapter = new ExpandableListViewAdapter(this);
        // TextView en = new TextView(this);
        mElv.addHeaderView(headerView);
        mElv.setAdapter(mExpandableListViewAdapter);
        mElv.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent,
                                        View v, int groupPosition, long id) {
                cityNameView.setText(mDatas.get(groupPosition).cityName);
                //cidView.setText(mDatas.get(groupPosition).cityId + "");
                cityId = mDatas.get(groupPosition).cityId;
                return false;
            }
        });

        mElv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent,
                                        View v, int groupPosition, int childPosition,
                                        long id) {
                Toast.makeText(OfflineDemo.this, "hahaww", Toast.LENGTH_SHORT).show();

                //Log.e("ss", "groupPosition=" + groupPosition+ ",childPosition=" + childPosition);
                return false;
            }
        });
        mElv.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
            @Override
            public void onGroupExpand(int groupPosition) {
                int count = mElv.getExpandableListAdapter().getGroupCount();
                for (int j = 0; j < count; j++) {
                    if (j != groupPosition) {
                        mElv.collapseGroup(j);
                    }
                }
            }
        });
        

        LinearLayout cl = findViewById(R.id.citylist_layout);
        LinearLayout lm = findViewById(R.id.localmap_layout);
        lm.setVisibility(View.GONE);
        cl.setVisibility(View.VISIBLE);

        // 获取已下过的离线地图信息
        localMapList = mOffline.getAllUpdateInfo();
        if (localMapList == null) {
            localMapList = new ArrayList<>();
        }
        ListView localMapListView = (ListView) findViewById(R.id.localmaplist);
        lAdapter = new LocalMapAdapter();
        localMapListView.setAdapter(lAdapter);

        ImageButton activity_ib_back = (ImageButton) findViewById(R.id.activity_ib_back);
        activity_ib_back.setOnClickListener(this);
        TextView activity_tv_title = (TextView) findViewById(R.id.activity_tv_title);
        TextView activity_tv_save = (TextView) findViewById(R.id.activity_tv_save);

        activity_tv_save.setVisibility(View.INVISIBLE);
        activity_tv_title.setText("离线地图");
        clButton = (Button) findViewById(R.id.clButton);

        localButton = (Button) findViewById(R.id.localButton);
        clButton1=findViewById(R.id.clButton1);
        clButton1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(OfflineDemo.this,MainActivityExPanderListView.class));
            }
        });


        cityNameView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

                if ("".contentEquals(charSequence)) {
                    search.setVisibility(View.GONE);
                } else {
                    search.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });

        search.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                ArrayList<MKOLSearchRecord> records = mOffline.searchCity(cityNameView
                        .getText().toString());

                if (records == null || records.size() != 1) {
                    Toast.makeText(OfflineDemo.this, "不支持该城市离线地图", Toast.LENGTH_SHORT).show();
                    return;
                }

                cityNameView.setText(String.valueOf(records.get(0).cityName));
                cityId = records.get(0).cityID;
            }
        });
    }

    private static int cityId;
    private boolean isFirst=true;

    /**
     * 切换至城市列表
     *
     * @param view
     */
    public void clickCityListButton(View view) {
        isFirst=true;
        LinearLayout cl = (LinearLayout) findViewById(R.id.citylist_layout);
        LinearLayout lm = (LinearLayout) findViewById(R.id.localmap_layout);
        clButton.setBackgroundResource(R.drawable.btn_shape);
        clButton.setTextColor(Color.rgb(255, 255, 255));
        localButton.setBackgroundResource(R.drawable.btn_shape_white);
        localButton.setTextColor(Color.rgb(51, 51, 51));
        lm.setVisibility(View.GONE);
        cl.setVisibility(View.VISIBLE);

    }

    /**
     * 切换至下载管理列表
     *
     * @param view
     */
    public void clickLocalMapListButton(View view) {
        isFirst=false;
        LinearLayout cl = (LinearLayout) findViewById(R.id.citylist_layout);
        LinearLayout lm = (LinearLayout) findViewById(R.id.localmap_layout);
        localButton.setBackgroundResource(R.drawable.btn_shape);
        localButton.setTextColor(Color.rgb(255, 255, 255));
        clButton.setBackgroundResource(R.drawable.btn_shape_white);
        clButton.setTextColor(Color.rgb(51, 51, 51));
        lm.setVisibility(View.VISIBLE);
        cl.setVisibility(View.GONE);
    }

    /**
     * 搜索离线需市
     *
     * @param view
     */
    /*public void search(View view) {
        ArrayList<MKOLSearchRecord> records = mOffline.searchCity(cityNameView
                .getText().toString());

        if (records == null || records.size() != 1) {
            Toast.makeText(this, "不支持该城市离线地图", Toast.LENGTH_SHORT).show();
            return;
        }

        cidView.setText(String.valueOf(records.get(0).cityID));
    }*/

    /**
     * 开始下载
     *
     * @param view
     */
    public void start(View view) {
        mOffline.start(cityId);
        clickLocalMapListButton(null);
        MyUtils.getToast(this,"开始下载离线地图. cityid: " + cityId);
        updateView();
    }

    /**
     * 暂停下载
     *
     * @param view
     */
    public void stop(View view) {

        mOffline.pause(cityId);
        MyUtils.getToast(this,"暂停下载离线地图. cityid: " + cityId);
        updateView();
    }


    /**
     * 删除离线地图
     *
     * @param view
     */
    /*public void remove(View view) {
        int cityid = Integer.parseInt(cidView.getText().toString());
        mOffline.remove(cityid);
        Toast.makeText(this, "删除离线地图. cityid: " + cityid, Toast.LENGTH_SHORT).show();
        updateView();
    }*/

    /**
     * 更新状态显示
     */
    public void updateView() {
        localMapList = mOffline.getAllUpdateInfo();
        if (localMapList == null) {
            localMapList = new ArrayList<MKOLUpdateElement>();
        }
        lAdapter.notifyDataSetChanged();
    }

    @Override
    protected void onPause() {
        MKOLUpdateElement temp = mOffline.getUpdateInfo(cityId);
        if (temp != null && temp.status == MKOLUpdateElement.DOWNLOADING) {
            mOffline.pause(cityId);
        }
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
    /**
     * 退出时，销毁离线地图模块
     */
    @Override
    protected void onDestroy() {

        mOffline.destroy();
        super.onDestroy();
    }

    @SuppressLint("DefaultLocale")
    @Override
    public void onGetOfflineMapState(int type, int state) {
        switch (type) {
            case MKOfflineMap.TYPE_DOWNLOAD_UPDATE: {
                MKOLUpdateElement update = mOffline.getUpdateInfo(state);
                // 处理下载进度更新提示
                if (update != null) {
                    //stateView.setText(String.format("%s : %d%%", update.cityName, update.ratio));
                    updateView();
                }
            }
            break;

            case MKOfflineMap.TYPE_NEW_OFFLINE:
                // 有新离线地图安装
                Log.d("OfflineDemo", String.format("add offlinemap num:%d", state));
                break;

            case MKOfflineMap.TYPE_VER_UPDATE:
                // 版本更新提示
                // MKOLUpdateElement e = mOffline.getUpdateInfo(state);
                break;

            default:
                break;
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_ib_back:
                finish();
                break;
        }
    }

    /**
     * 离线地图管理列表适配器
     */
    public class LocalMapAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return localMapList.size();
        }

        @Override
        public Object getItem(int index) {
            return localMapList.get(index);
        }

        @Override
        public long getItemId(int index) {
            return index;
        }

        @SuppressLint("ViewHolder")
        @Override
        public View getView(int index, View view, ViewGroup arg2) {
            MKOLUpdateElement e = (MKOLUpdateElement) getItem(index);
            view = View.inflate(OfflineDemo.this,
                    R.layout.offline_localmap_list, null);
            initViewItem(view, e);
            return view;
        }

        @SuppressLint("SetTextI18n")
        void initViewItem(View view, final MKOLUpdateElement e) {
            final Button display = view.findViewById(R.id.display);
            Button remove = view.findViewById(R.id.remove);
            TextView title =  view.findViewById(R.id.title);
            TextView update =  view.findViewById(R.id.update);
            TextView ratio = view.findViewById(R.id.ratio);
            Button btn_update = view.findViewById(R.id.btn_update);
            ratio.setText(e.ratio + "%");
            title.setText(e.cityName);


            if (e.update) {
                update.setText("可更新");
                btn_update.setText("更新");
                btn_update.setTextColor(Color.parseColor("#FF4081"));
                btn_update.setEnabled(true);
            } else {
                update.setText("最新");
                btn_update.setText("最新");
                btn_update.setTextColor(Color.parseColor("#ffffff"));
                btn_update.setEnabled(false);
            }

            if (e.ratio != 100) {
                display.setText("继续");
                //display.setEnabled(false);
            } else {
                display.setText("查看");
                display.setEnabled(true);
            }

            remove.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    final NormalDialog dialog = new NormalDialog(context);
                    dialog.content("您确定要删除吗?")//
                            .style(NormalDialog.STYLE_TWO)//
                            .btnNum(2)
                            .title("删除提示")
                            .btnText("取消", "删除")//
                            .show();
                    dialog.setOnBtnClickL(
                            new OnBtnClickL() {
                                @Override
                                public void onBtnClick() {
                                    dialog.dismiss();
                                }
                            }, new OnBtnClickL() {
                                @Override
                                public void onBtnClick() {
                                    mOffline.remove(e.cityID);
                                    updateView();

                                    dialog.dismiss();
                                }
                            });

                }
            });

            display.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {

                    if (e.ratio != 100) {
                        display.setText("继续");
                        mOffline.start(e.cityID);
                    } else {
                        display.setText("查看");
                        Intent intent = new Intent();
                        intent.putExtra("customStyle", true);
                        intent.putExtra("x", e.geoPt.longitude);
                        intent.putExtra("y", e.geoPt.latitude);
                        intent.putExtra("level", 13.0f);
                        intent.setClass(OfflineDemo.this, OfflineMapActivity.class);
                        startActivity(intent);
                    }


                }
            });

            btn_update.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    //Log.e(TAG, "onClick: 点击更新按钮" );
                    mOffline.update(e.cityID);//更新下载
                    if (e.ratio != 100) {
                        display.setEnabled(false);
                    } else {
                        display.setEnabled(true);
                    }
                }
            });
        }

    }
    //头部适配器
    class ListViewsExpanderTop extends BaseAdapter {
        Context context;

        ListViewsExpanderTop(Context context) {
            this.context = context;
        }


        @Override
        public int getCount() {
            //Log.e("count",hotCities.size()+"");
            return hotCities.size();
        }

        @Override
        public Object getItem(int i) {
            return hotCities.get(i);
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            ListViewsExpanderTop.ViewHolderItmeTop vi;
            if (view == null) {
                vi = new ListViewsExpanderTop.ViewHolderItmeTop();
                view = LayoutInflater.from(context).inflate(R.layout.activity_about_lintop, null);
                vi.textView = view.findViewById(R.id.tv_content);
                view.setTag(vi);

            } else {
                vi = (ViewHolderItmeTop) view.getTag();
            }
            vi.textView.setText(hotCities.get(i));

            return view;
        }

        class ViewHolderItmeTop {
            TextView textView;
        }
    }
    class ExpandableListViewAdapter extends BaseExpandableListAdapter {

        LayoutInflater mInflater;
        Context context;

        public ExpandableListViewAdapter(Context context) {
            mInflater = LayoutInflater.from(context);
            this.context = context;
        }

        @Override
        public Object getChild(int groupPosition, int childPosition) {
            return mDatas.get(groupPosition).citychildList.get(childPosition);
        }

        @Override
        public long getChildId(int groupPosition, int childPosition) {
            return groupPosition;
        }

        @Override
        public View getChildView(int groupPosition, int childPosition,
                                 boolean isLastChild, View convertView, ViewGroup parent) {
            if (convertView == null) {
                mViewChild = new OfflineDemo.ExpandableListViewAdapter.ViewChild();
                convertView = mInflater.inflate(R.layout.channel_expandablelistview_item, null);
                mViewChild.gridView = (ListView) convertView.findViewById(R.id.channel_item_child_gridView);
                convertView.setTag(mViewChild);
            } else {
                mViewChild = (ExpandableListViewAdapter.ViewChild) convertView.getTag();
            }
            //Log.e("resultItem="+groupPosition,mDatas.get(groupPosition).citychildList.toString());
            CityChildAdapter cityChlder = new CityChildAdapter(mDatas.get(groupPosition).citychildList, context);
            mViewChild.gridView.setAdapter(cityChlder);
            setGridViewListener(mViewChild.gridView,groupPosition);
            mViewChild.gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

            return convertView;
        }

        /**
         * 设置gridview点击事件监听
         *
         * @param gridView
         */
        private void setGridViewListener(final ListView gridView, final int groupid) {
            gridView.setOnItemClickListener(new ListView.OnItemClickListener() {
                @SuppressLint("SetTextI18n")
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                                        int position, long id) {
                    Toast.makeText(context,mDatas.get(groupid).citychildList.get(position).cityChildId+"",Toast.LENGTH_LONG).show();
                    cityNameView.setText(mDatas.get(groupid).citychildList.get(position).cityChildName);
                    //cidView.setText(mDatas.get(groupid).citychildList.get(position).cityChildId + "");
                    cityId = mDatas.get(groupid).citychildList.get(position).cityChildId;
                }
            });
        }

        /**
         * 设置gridview数据
         *
         * @param data
         * @return
         */
        private ArrayList<HashMap<String, Object>> setGridViewData(String[] data) {
            ArrayList<HashMap<String, Object>> gridItem = new ArrayList<HashMap<String, Object>>();
            for (int i = 0; i < data.length; i++) {
                HashMap<String, Object> hashMap = new HashMap<String, Object>();
                hashMap.put("channel_gridview_item", data[i]);
                gridItem.add(hashMap);
            }
            return gridItem;
        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return 1;
        }

        @Override
        public Object getGroup(int groupPosition) {
            return mDatas.get(groupPosition);
        }

        @Override
        public int getGroupCount() {
            return mDatas.size();
        }

        @Override
        public long getGroupId(int groupPosition) {
            return groupPosition;
        }

        @Override
        public View getGroupView(int groupPosition, boolean isExpanded,
                                 View convertView, ViewGroup parent) {
            if (convertView == null) {
                mViewChild = new ExpandableListViewAdapter.ViewChild();
                convertView = mInflater.inflate(
                        R.layout.channel_expandablelistview, null);
                mViewChild.textView = convertView
                        .findViewById(R.id.channel_group_name);
                mViewChild.imageView = convertView
                        .findViewById(R.id.channel_imageview_orientation);
                convertView.setTag(mViewChild);
            } else {
                mViewChild = (ExpandableListViewAdapter.ViewChild) convertView.getTag();
            }

            if (isExpanded) {
                mViewChild.imageView
                        .setImageResource(R.drawable.expander_listclose);
            } else {
                mViewChild.imageView
                        .setImageResource(R.drawable.expander_listview);
            }
            mViewChild.textView.setText(mDatas.get(groupPosition).cityName);
            return convertView;
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

        ExpandableListViewAdapter.ViewChild mViewChild;

        class ViewChild {
            ImageView imageView;
            TextView textView;
            ListView gridView;
        }
    }


    /**
     * V4.5.0起，保证数据不溢出，使用long型保存数据包大小结果
     */
    @SuppressLint("DefaultLocale")
    public String formatDataSize(long size) {
        String ret;
        if (size < (1024 * 1024)) {
            ret = String.format("%dK", size / 1024);
        } else {
            ret = String.format("%.1fM", size / (1024 * 1024.0));
        }
        return ret;
    }
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            //返回键判断：如果是下载管理那么点击退出键盘那么跳转到城市列表。不然finish解决用户体验和下载问题。
            if(isFirst){
                finish();
            }else{
                clickCityListButton(cityNameView);
            }
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }
}